package com.yuncheng.spcyApi.vo.common;


import com.yuncheng.vo.HttpResult;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 结果集返回-新加一层
 */
public class HttpResultVo {
    public static HttpResult HttpResultList(Object data){
        Map result = new HashMap();
        result.put("records", data);
        return HttpResult.ok(result);
    }

    public static HttpResult HttpResultListMap(Object data){
        Map result = new HashMap();
        result.put("list", data);
        return HttpResult.ok(result);
    }

    public static HttpResult HttpResultPageList(List<?> data){
        Map result = new HashMap();
        result.put("records", data);
        result.put("total", data.size());
        result.put("size", data.size());
        result.put("current", "1");
        return HttpResult.ok(result);
    }

    public static HttpResult HttpResultSave(Object data){
        HttpResult result = new HttpResult(true);
        result.setResult(data);
        result.setMessage("保存成功");
        return result;
    }

    public static HttpResult HttpResultSave(Object data, String msg){
        HttpResult result = new HttpResult(true);
        result.setResult(data);
        result.setMessage(msg);
        return result;
    }

    public static HttpResult HttpResultGet(Object data){
        HttpResult result = new HttpResult(true);
        result.setResult(data);
        result.setMessage("操作成功");
        return result;
    }
}
